from fastapi import APIRouter

from backend.app.common.response.response_schema import response_base
from backend.app.schemas.device import TenderReq
from backend.app.schemas.search import AISearchReq, MeterMatchSchema
from backend.app.services.search_service import AISearchService, MatchDeviceAttribute
from backend.app.services.tender_search import tender_search

router = APIRouter()


@router.post('/match', summary='匹配标书')
async def math_device_new(req: TenderReq):
    output = await tender_search(req)
    return await response_base.success(data=output)


@router.post('/ai_search', summary='设备AI搜索')
async def search_ai(req: AISearchReq):
    goods = await AISearchService.search(req)
    return await response_base.success(data=goods)


@router.post('/attribute_match', summary='设备属性识别接口')
async def attribute_match(req: MeterMatchSchema):
    goods = await MatchDeviceAttribute().search(req)
    return await response_base.success(data=goods)

